<?php
    $event      = $data['Event'];
    $members    = $data['Member'];
    $guests     = $data['Guest'];
    $chronicles = $data['Chronicle'];
    $parent     = $data['EventParent'];
    $program    = $data['EventsRepertoire'];
    
    $parentLabel = '';
    if ($parent['id']) {
        $parentLabel = sprintf("%s (%s - %s)", $parent['name'], 
                                   date_local($parent['start']), 
                                   date_local($parent['end']) );
    }
    
?>
<button class="btn-print fixed no-print" onclick="window.print()"><?= __('Print') ?></button>
<h1>
    <? if(! empty($parent['id'])): ?>
        <?= $parent['name'] ?>, 
    <? endif ?>
    <?= $event['name'] ?>
</h1>

<p><?= date_local($event['start']) ?><? 
    if (! empty($event['end'])): ?> - <?= date_local($event['end']) ?><? endif ?>,
    <?= $conductors[(int)$event['conductor_id']] ?>
</p>

<? if (! empty($event['description'])): ?>
<p style="margin:10px"><i><?= $event['description'] ?></i></p>
<? endif ?>

<div class="left span50p">
    <h2><?= strtotitle(__('members')) ?></h2>
    <? foreach ($voices as $voice): ?>
        <p class="list"><span><?= __($voice) ?>:</span> <?= @implode(', ', $allMembersByVoice[$voice]) ?></p>
    <? endforeach ?>
</p>
</div>

<div class="left span40p" style="margin-left:10px">
    <h2><?= strtotitle(__('guests')) ?></h2>
    <? foreach ($guests as $guest): ?>
        <p><?= $guest['name'] ?></p>
    <? endforeach ?>
</p>
</div><br clear="all">

<h2 style="margin:40px 0 10px"><?= strtotitle(__('program')) ?></h2>
<div style="margin-left:20px">
<? foreach ($program as $repertoireId => $p): ?>
<strong><?= $repertoire[$repertoireId] ?></strong>
<?
    function membersWalk(&$item, $index, $allMembers){
        $item = $allMembers[(int)$item['member_id']];
    }
    array_walk($p['members'], 'membersWalk', $allMembers);
    
    function guestsWalk(&$item, $index, $allGuests){
        $item = $allGuests[(int)$item['guest_id']];
    }
    array_walk($p['guests'], 'guestsWalk', $allGuests);
?>
<p class="list"><span><?= __('members') ?>:</span> <?= @implode(', ', $p['members']) ?></p>
<p class="list"><span><?= __('guests') ?>:</span> <?= @implode(', ', $p['guests']) ?></p>
<? endforeach ?>
</div>